home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / Interfaces & Libraries / Interfaces / CIncludes / ConditionalMacros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-15  |  8.8 KB  |  264 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ConditionalMacros.h
  3.  
  4.      Contains:    Compile time feature switches to achieve platform independent sources.
  5.  
  6.      Version:    Technology:    Universal Interface Files 2.1.2
  7.                  Package:    Universal Interfaces 2.1.2 on ETO #20
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21. #define __CONDITIONALMACROS__
  22.  
  23. /*
  24.     This file sets up the following compiler independent conditionals:
  25.     
  26.     GENERATINGPOWERPC        - Compiler is generating PowerPC instructions
  27.     GENERATING68K            - Compiler is generating 68k family instructions
  28.     GENERATING68881            - Compiler is generating mc68881 floating point instructions
  29.     GENERATINGCFM            - Code being generated assumes CFM calling conventions
  30.     CFMSYSTEMCALLS            - No A-traps.  Systems calls are made using CFM and UPP's
  31.     
  32.     SystemSevenFiveOrLater    - Compiled code will only be run on a System 7.5 or later Macintosh
  33.     SystemSevenOrLater        - Compiled code will only be run on a System 7.0 or later Macintosh
  34.     SystemSixOrLater        - Compiled code will only be run on a System 6.0 or later Macintosh
  35.                               A developer should set the appropriate flag on the compiler command-
  36.                               line or in a file processed before this file.  This will allow the
  37.                               certain optimizations to be made which can result in smaller, faster
  38.                               applications.
  39.     
  40.     CGLUESUPPORTED            - Interface library will support "C glue" functions (function names
  41.                               are: all lowercase, use C strings instead of pascal strings, use 
  42.                               Point* instead of Point).
  43.  
  44.     OLDROUTINENAMES            - "Old" names for Macintosh system calls are allowed in source code.
  45.                               (e.g. DisposPtr instead of DisposePtr). The names of system routine
  46.                               are now more sensitive to change because CFM binds by name.  In the 
  47.                               past, system routine names were compiled out to just an A-Trap.  
  48.                               Macros have been added that each map an old name to its new name.  
  49.                               This allows old routine names to be used in existing source files,
  50.                               but the macros only work if OLDROUTINENAMES is true.  This support
  51.                               will be removed in the near future.  Thus, all source code should 
  52.                               be changed to use the new names! You can set OLDROUTINENAMES to false
  53.                               to see if your code has any old names left in it.
  54.     
  55.     OLDROUTINELOCATIONS     - "Old" location of Macintosh system calls are used.  For example, c2pstr 
  56.                               has been moved from Strings to TextUtils.  It is conditionalized in
  57.                               Strings with OLDROUTINELOCATIONS and in TextUtils with !OLDROUTINELOCATIONS.
  58.                               This allows developers to upgrade to newer interface files without suddenly
  59.                               all their code not compiling becuase of "incorrect" includes.  But, it
  60.                               allows the slow migration of system calls to more understandable file
  61.                               locations.  OLDROUTINELOCATIONS currently defaults to true, but eventually
  62.                               will default to false.
  63.     
  64.     PRAGMA_ALIGN_SUPPORTED    - Compiler supports "#pragma align=..." directives. The only compilers that
  65.                               can get by without supporting the pragma are old classic 68K compilers
  66.                               that will only be used to compile older structs that have 68K alignment
  67.                               anyways.  
  68.     
  69.     PRAGMA_IMPORT_SUPPORTED    - Compiler supports "#pragma import on/off" directives.  These directives
  70.                               were introduced with the SC compiler which supports CFM 68K.  The directive
  71.                               is used to tell the compiler which functions will be called through a 
  72.                               transition vector (instead of a simple PC-relative offset).  This allows 
  73.                               the compiler to generate better code.  Since System Software functions are
  74.                               implemented as shared libraries and called through transition vectors,
  75.                               all System Software functions are declared with "#pragma import on".
  76.                               
  77.     
  78.     There are some invariants among the conditionals:
  79.     
  80.     GENERATINGPOWERPC != GENERATING68K
  81.     GENERATING68881 => GENERATING68K
  82.     GENERATINGPOWERPC => GENERATINGCFM
  83.     GENERATINGPOWERPC => CFMSYSTEMCALLS
  84.     CFMSYSTEMCALLS => GENERATINGCFM
  85.     GENERATINGPOWERPC => SystemSevenOrLater
  86.     SystemSevenFiveOrLater => SystemSevenOrLater
  87.     SystemSevenOrLater => SystemSixOrLater
  88.     PRAGMA_IMPORT_SUPPORTED => CFMSYSTEMCALLS
  89.     
  90. */
  91. /*
  92.  
  93.     Set up UNIVERSAL_INTERFACES_VERSION
  94.     
  95.         0x212 => version 2.12
  96.         0x210 => version 2.1
  97.         This conditional did not exist prior to version 2.1
  98. */
  99. #define UNIVERSAL_INTERFACES_VERSION 0x0212
  100. /*
  101.  
  102.     Set up GENERATINGPOWERPC and GENERATING68K
  103.  
  104. */
  105. #ifdef GENERATINGPOWERPC
  106.     #ifndef GENERATING68K
  107. #define GENERATING68K !GENERATINGPOWERPC
  108.     #endif
  109. #endif
  110. #ifdef GENERATING68K
  111.     #ifndef GENERATINGPOWERPC
  112. #define GENERATINGPOWERPC !GENERATING68K
  113.     #endif
  114. #endif
  115. #ifndef GENERATINGPOWERPC
  116.     #if defined(powerc) || defined(__powerc)
  117. #define GENERATINGPOWERPC 1
  118.     #else
  119. #define GENERATINGPOWERPC 0
  120.     #endif
  121. #endif
  122. #ifndef GENERATING68K
  123.     #if GENERATINGPOWERPC
  124. #define GENERATING68K 0
  125.     #else
  126. #define GENERATING68K 1
  127.     #endif
  128. #endif
  129. /*
  130.  
  131.     Set up GENERATING68881 
  132.  
  133. */
  134. #if GENERATING68K
  135.     #if defined(applec) || defined(__SC__)
  136.         #ifdef mc68881
  137. #define GENERATING68881 1
  138.         #endif
  139.     #else
  140.         #ifdef __MWERKS__
  141.             #if __MC68881__
  142. #define GENERATING68881 1
  143.             #endif
  144.         #endif
  145.     #endif
  146. #endif
  147. #ifndef GENERATING68881
  148. #define GENERATING68881 0
  149. #endif
  150. /*
  151.  
  152.     Set up GENERATINGCFM and  CFMSYSTEMCALLS
  153.  
  154. */
  155. #if GENERATINGPOWERPC || defined(__CFM68K__)
  156. #define GENERATINGCFM 1
  157. #define CFMSYSTEMCALLS 1
  158. #else
  159. #define GENERATINGCFM 0
  160. #define CFMSYSTEMCALLS 0
  161. #endif
  162. /*
  163.  
  164.     Set up SystemSevenFiveOrLater, SystemSevenOrLater, and SystemSixOrLater
  165.  
  166. */
  167. #ifndef SystemSevenFiveOrLater
  168. #define SystemSevenFiveOrLater 0
  169. #endif
  170. #ifndef SystemSevenOrLater
  171.     #if GENERATINGCFM
  172. #define SystemSevenOrLater 1
  173.     #else
  174. #define SystemSevenOrLater SystemSevenFiveOrLater
  175.     #endif
  176. #endif
  177. #ifndef SystemSixOrLater
  178. #define SystemSixOrLater SystemSevenOrLater
  179. #endif
  180. /*
  181.  
  182.     Set up OLDROUTINENAMES and OLDROUTINELOCATIONS
  183.  
  184. */
  185. #ifndef OLDROUTINENAMES
  186. #define OLDROUTINENAMES 1
  187. #endif
  188. #ifndef OLDROUTINELOCATIONS
  189. #define OLDROUTINELOCATIONS 1
  190. #endif
  191. /*
  192.  
  193.     Define C specific conditionals
  194.  
  195. */
  196. #ifndef CGLUESUPPORTED
  197.     #ifdef THINK_C
  198. #define CGLUESUPPORTED 0
  199.     #else
  200. #define CGLUESUPPORTED 1
  201.     #endif
  202. #endif
  203. #ifndef PRAGMA_ALIGN_SUPPORTED
  204.     #if GENERATINGPOWERPC || defined(__MWERKS__) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  205.         #define  PRAGMA_ALIGN_SUPPORTED 1
  206.     #else
  207.         #define  PRAGMA_ALIGN_SUPPORTED 0
  208.     #endif
  209. #endif
  210. #ifndef PRAGMA_IMPORT_SUPPORTED
  211.     #if ( defined(__MWERKS__) && (__MWERKS__ >= 0x0700) ) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  212. #define PRAGMA_IMPORT_SUPPORTED 1
  213.     #else
  214. #define PRAGMA_IMPORT_SUPPORTED 0
  215.     #endif
  216. #endif
  217. /*
  218.  
  219.     Set up old "USES..." conditionals to support 1.0 universal interface files
  220.  
  221.     The USESxxx names are old, but cannot be removed yet because source code that
  222.     uses them might still compile, but do the wrong thing. 
  223. */
  224. #ifndef USES68KINLINES
  225. #define USES68KINLINES GENERATING68K
  226. #endif
  227. #define USESCODEFRAGMENTS GENERATINGCFM
  228. #define USESROUTINEDESCRIPTORS GENERATINGCFM
  229. /*
  230.     The following macros isolate the use of inlines from the routine prototypes.
  231.     A routine prototype will always be followed by on of these inline macros with
  232.     a list of the opcodes to be inlined.  On the 68K side, the appropriate inline
  233.     code will be generated.  On platforms that use code fragments, the macros are
  234.     essentially NOPs.
  235. */
  236. #if CFMSYSTEMCALLS
  237. #define ONEWORDINLINE(trapNum)
  238. #define TWOWORDINLINE(w1,w2)
  239. #define THREEWORDINLINE(w1,w2,w3)
  240. #define FOURWORDINLINE(w1,w2,w3,w4)
  241. #define FIVEWORDINLINE(w1,w2,w3,w4,w5)
  242. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
  243. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
  244. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
  245. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
  246. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
  247. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
  248. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
  249. #else
  250. #define ONEWORDINLINE(trapNum) = trapNum
  251. #define TWOWORDINLINE(w1,w2) = {w1,w2}
  252. #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
  253. #define FOURWORDINLINE(w1,w2,w3,w4)  = {w1,w2,w3,w4}
  254. #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
  255. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)     = {w1,w2,w3,w4,w5,w6}
  256. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)      = {w1,w2,w3,w4,w5,w6,w7}
  257. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)      = {w1,w2,w3,w4,w5,w6,w7,w8}
  258. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
  259. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)  = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
  260. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
  261. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
  262. #endif
  263. #endif /* __CONDITIONALMACROS__ */
  264.